import { WuXingBasePanel } from "../../wuxing/WuXingBasePanel";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { WuXingSkillList } from "../../wuxing/WuXingSkillList";
import { WXToolTipSprite } from "./WXToolTipSprite";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { GImageBitmap } from "../../../../../com/mui/controls/GImageBitmap";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { ResouceConst } from "../../../../component/gconst/ResouceConst";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { Language } from "../../../../../extend/language/Language";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { WuXingPlayerInfo } from "../../../model/wuxing/WuXingPlayerInfo";
import { ColorConfig } from "../../../resource/ColorConfig";
import { WuXingRule } from "../../../rules/WuXingRule";
import { GModuleEvent } from "../../../mvc/GModuleEvent";
import { Cache } from "../../../cache/Cache";
import { PlayerEqStrengthInfo } from "../equip/PlayerEqStrengthInfo";
import { WuXingCache } from "../../../cache/WuXingCache";
import { MagicWeaponUtil } from "../../magicWeapon/MagicWeaponUtil";
import { ScaleBitmap } from "../../../../../com/mui/display/ScaleBitmap";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
type int = number;
//class WuXingAttrPanel
    
    export  class WuXingAttrPanel extends WuXingBasePanel
    {
        constructor(arg1: int, arg2: int)
        {
            super(arg1, arg2);
            return;
        }

        public set mode(arg1: string)
        {
            this._mode = arg1;
            return;
        }

        /* internal  */onWuXingBgLoadedHandler(): void
        {
            this._titleBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.wxMingMai);
            this._titleBmp.x = (width - this._titleBmp.width) / 2;
            this._titleBmp.y = 10;
            this._wxIconBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.wxIcon);
            this._fightShanghai.bitmapData = GlobalClass.getBitmapData(ImagesConst.wxShangHaiFont);
            this._wxFightToolTipSprite.x = (width - this._fightShanghai.width) / 2;
            this._titleBg.width = this._fightShanghai.width + 40;
            this._titleBg.height = this._fightShanghai.height + 10;
            this._titleBg.x = this._fightShanghai.x - 20;
            this._titleBg.y = this._fightShanghai.y - 5;
            return;
        }

        protected createSkillList(): void
        {
            this._skillList = new WuXingSkillList(this._skillListBg.width, this._skillListBg.height, 60, false);
            this._skillList.x = this._skillListBg.x;
            this._skillList.y = this._skillListBg.y + 3;
            addChild(this._skillList);
            return;
        }

        protected createToolTipBody(): void
        {
            this._wxIconBody = new WXToolTipSprite(50, 50);
            this._wxIconBody.buttonMode = true;
            this._wxIconBody.x = 5;
            this._wxIconBody.y = 120;
            addChild(this._wxIconBody);
            this._wxIconBmp = new Object /* flash.display.Bitmap */();
            this._wxIconBody.addChild(this._wxIconBmp);
            this._numTxt = ObjCreate.createGTextField("", 0, 45, 50, 20, this._wxIconBody, GlobalStyle.textFormatGreen);
            this._numTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            return;
        }

        protected /* override */ initUI(): void
        {
            super.initUI();
            this._titleBmp = new Object /* flash.display.Bitmap */();
            addChild(this._titleBmp);
            this._skillListBg = ObjCreate.createBg(5, 30, width - 10, 86, this);
            this.createSkillList();
            this._wxBg = new GImageBitmap(ImagesConst.wxBg, 40, 158);
            addChild(this._wxBg);
            this._wxBg.visible = false;
            this._wxBgNew = new GImageBitmap(ImagesConst.wuxingShenglingFourAttBg, 1, 180);
            addChild(this._wxBgNew);
            this._wxBgNew.visible = false;
            this.createToolTipBody();
            var loc1=new GTextFormat("", 12, 16776960);
            loc1.align = flash.text.TextFormatAlign.CENTER;
            this._lingliTxt = ObjCreate.createGTextField("9999", 27, 197, 76, 20, this, loc1);
            loc1 = new GTextFormat("", 12, 16776960);
            loc1.align = flash.text.TextFormatAlign.CENTER;
            this._jiachengTxt = ObjCreate.createGTextField("9999", 194, this._lingliTxt.y, 80, 20, this, loc1);
            this._magicTx = ObjCreate.createGTextField("9999", 158, 220, 80, 20, this, loc1);
            this._shenglingTx = ObjCreate.createGTextField("9999", 241, 220, 80, 20, this, loc1);
            this._lingliTxt.defaultTextFormat = loc1;
            this._jiachengTxt.defaultTextFormat = loc1;
            this._magicTx.defaultTextFormat = loc1;
            this._shenglingTx.defaultTextFormat = loc1;
            loc1 = new GTextFormat(FontUtil.xingkaiName, 20, 16776960);
            this._fightValueTxt = ObjCreate.createGTextField("", 194, 302, 200, 30, this, loc1);
            this._fightShanghai = new Object /* flash.display.Bitmap */();
            addChild(this._fightShanghai);
            this._line = ResouceConst.getScaleBitmap(ImagesConst.SplitLine);
            this._line.width = width - 20;
            this._line.x = 10;
            this._line.y = 382;
            addChild(this._line);
            this._titleBg = ResouceConst.getScaleBitmap(ImagesConst.FightingStrgBg);
            addChild(this._titleBg);
            this._wxFightToolTipSprite = new WXToolTipSprite(230, 22);
            this._wxFightToolTipSprite.addChild(this._titleBg);
            this._wxFightToolTipSprite.addChild(this._fightShanghai);
            addChild(this._wxFightToolTipSprite);
            this._wxFightToolTipSprite.y = this._line.y - 35;
            this._wxFightToolTipSprite.toolTipData = HTMLUtil.addColor(Language.getString(26355), GlobalStyle.color1);
            this._mainAttrTxt = ObjCreate.createTextField("", 15, this._line.y + 10, 95, 20, this);
            this._skillTxt = ObjCreate.createTextField("", this._mainAttrTxt.x + 130, this._mainAttrTxt.y, 160, 20, this);
            this._otherTxt = ObjCreate.createTextField("", this._mainAttrTxt.x, this._skillTxt.y + 20, 272, 20, this);
            this._aboutTxt = ObjCreate.createTextField("", this._mainAttrTxt.x, this._otherTxt.y + 20, 272, 20, this);
            LoaderHelp.addResCallBack(ResFileConst.wuxing, this.onWuXingBgLoadedHandler);
            return;
        }

        public /* override */ updateData(arg1: WuXingPlayerInfo): void
        {
            super.updateData(arg1);
            this._skillList.updateData(arg1);
            this._lingliTxt.text = arg1.totalEnergy.toString();
            this._jiachengTxt.text = arg1.vitalsAddition + "%";
            this._fightValueTxt.text = arg1.fightValue.toString();
            this._mainAttrTxt.htmlText = HTMLUtil.addColor(HTMLUtil.addColor(Language.getString(26379), GlobalStyle.color1) + arg1.getMainAttrHtmlName() + HTMLUtil.addColor(Language.getString(26383) + "(" + arg1.getAttrValue(arg1.mainAttribute) + ")", ColorConfig.instance.getWuxingColor(arg1.mainAttribute)), GlobalStyle.color1);
            this._skillTxt.htmlText = HTMLUtil.addColor(HTMLUtil.addColor(Language.getString(26382), GlobalStyle.color1) + HTMLUtil.addColor(arg1.skillLevel + Language.getString(27515) + arg1.skillName + "(" + arg1.getSkillEffectStr(arg1.mainAttribute) + ")", ColorConfig.instance.getWuxingColor(arg1.mainAttribute)), GlobalStyle.color1);
            this._otherTxt.htmlText = HTMLUtil.addColor(WuXingRule.getRelationStr(arg1.mainAttribute, WuXingRule.Relation_DelTo) + "：" + Language.getStringByParam(26406, WuXingRule.getRelationName(arg1.mainAttribute, WuXingRule.Relation_DelTo)), GlobalStyle.color1);
            this._aboutTxt.htmlText = HTMLUtil.addColor(WuXingRule.getRelationStr(arg1.mainAttribute, WuXingRule.Relation_DelFrom) + "：" + Language.getStringByParam(26407, WuXingRule.getRelationName(arg1.mainAttribute, WuXingRule.Relation_DelFrom)), GlobalStyle.color1);
            if (this._mode == GModuleEvent.Mode_Self) 
            {
                this.updateAttrTxPos(Cache.instance.role.entityInfo.level);
            }
            return;
        }

        public /* override */ updateRolePack(): void
        {
            super.updateRolePack();
            this._wxIconBody.toolTipData = PlayerEqStrengthInfo.getSpriteTargetToolTip(GModuleEvent.Mode_Self);
            this._numTxt.text = Language.getStringByParam(26421, PlayerEqStrengthInfo.wxNum);
            if (this._mode == GModuleEvent.Mode_Self) 
            {
                this.updateAttrTxPos(Cache.instance.role.entityInfo.level);
            }
            return;
        }

        public updateAttrTxPos(arg1: int): void
        {
            if (arg1 < WuXingCache.SHENGLINGOPENLV) 
            {
                this._wxBg.visible = true;
                this._lingliTxt.x = 40;
                this._lingliTxt.y = 209;
                this._jiachengTxt.x = 206;
                this._jiachengTxt.y = 209;
                this._fightValueTxt.y = 302;
                this._wxBgNew.visible = false;
                this._magicTx.visible = false;
                this._shenglingTx.visible = false;
            }
            else 
            {
                this._wxBg.visible = false;
                this._lingliTxt.x = 0;
                this._lingliTxt.y = 220;
                this._jiachengTxt.x = 78;
                this._jiachengTxt.y = 220;
                this._fightValueTxt.y = 315;
                this._wxBgNew.visible = true;
                this._magicTx.visible = true;
                this._shenglingTx.visible = true;
            }
            this.updateWxMagicAndSLTxValue(Cache.instance.pack.rolePackCache.magicWeaponItems, Cache.instance.pack.rolePackCache.getEquipItems());
            return;
        }

        public updateWxMagicAndSLTxValue(arg1: Array<any>, arg2: Array<any>): void
        {
            this._magicTx.text = MagicWeaponUtil.getTotalMagicWeaponWuXingFight(arg1).toString();
            this._shenglingTx.text = WuXingRule.getAllShengLingFight(arg2).toString();
            return;
        }

        protected /* var */_titleBmp: Object /* flash.display.Bitmap */;

        protected /* var */_skillListBg: ScaleBitmap;

        protected /* var */_skillList: WuXingSkillList;

        protected /* var */_wxIconBody: WXToolTipSprite;

        protected /* var */_wxIconBmp: Object /* flash.display.Bitmap */;

        protected /* var */_numTxt: GTextFiled;

        protected /* var */_wxBg: Object /* flash.display.Bitmap */;

        protected /* var */_wxBgNew: Object /* flash.display.Bitmap */;

        protected /* var */_lingliTxt: GTextFiled;

        protected /* var */_jiachengTxt: GTextFiled;

        protected /* var */_fightValueTxt: GTextFiled;

        protected /* var */_magicTx: GTextFiled;

        protected /* var */_shenglingTx: GTextFiled;

        protected /* var */_titleBg: ScaleBitmap;

        protected /* var */_fightShanghai: Object /* flash.display.Bitmap */;

        protected /* var */_wxFightToolTipSprite: WXToolTipSprite;

        protected /* var */_line: ScaleBitmap;

        protected /* var */_mainAttrTxt: Object /* flash.text.TextField */;

        protected /* var */_skillTxt: Object /* flash.text.TextField */;

        protected /* var */_otherTxt: Object /* flash.text.TextField */;

        protected /* var */_aboutTxt: Object /* flash.text.TextField */;

        protected /* var */_mode: string;
    }
